//
//  RSSubViewController.m
//  H5Store
//
//  Created by Ran10 on 14-9-23.
//  Copyright (c) 2014年 Ran10. All rights reserved.
//

#import "RSSubViewController.h"

@interface RSSubViewController (){
    UILabel *_signalLabel;
}

@end

@implementation RSSubViewController

- (id)initWithFrame:(CGRect)frame andSignal:(NSString *)szSignal{
    self = [super init];
    if (self){
        self.szSignal = szSignal;
        self.view.frame = frame;
        self.title = szSignal;
        [self.view setBackgroundColor:[UIColor whiteColor]];
        self.view.layer.borderWidth = 1;
        self.view.layer.borderColor = [UIColor blueColor].CGColor;
    }
    return self;
}

- (void)viewDidLoad{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    
    UIButton *backbtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [backbtn setFrame:CGRectMake(20, 40, 60, 30)];
    [backbtn setTitle:@"返回" forState:UIControlStateNormal];
    [backbtn setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    [backbtn setTitleColor:[UIColor greenColor] forState:UIControlStateHighlighted];
    backbtn.layer.borderWidth = 1;
    backbtn.layer.borderColor = [UIColor blueColor].CGColor;
    backbtn.layer.masksToBounds = YES;
    backbtn.layer.cornerRadius = 6;
    [backbtn addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:backbtn];
    
    _signalLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 160, 90)];
    _signalLabel.text = self.szSignal;
    _signalLabel.textAlignment = NSTextAlignmentCenter;
    _signalLabel.contentMode = UIViewContentModeScaleAspectFill;
    [_signalLabel setBackgroundColor:[UIColor clearColor]];
    [_signalLabel setTextColor:[UIColor blackColor]];
    [_signalLabel setFont:[UIFont systemFontOfSize:20]];
    _signalLabel.center = self.view.center;
    [self.view addSubview:_signalLabel];
    _signalLabel.userInteractionEnabled = YES;
    _signalLabel.layer.borderWidth = 1;
    _signalLabel.layer.borderColor = [UIColor blueColor].CGColor;
    
    UITapGestureRecognizer *singleTapRecognizer = [[UITapGestureRecognizer alloc] init];
    singleTapRecognizer.numberOfTapsRequired = 1;
    [singleTapRecognizer addTarget:self action:@selector(pust2View:)];
    [_signalLabel addGestureRecognizer:singleTapRecognizer];
}

- (void)setSzSignal:(NSString *)szSignal{
    _szSignal = szSignal;
    _signalLabel.text = szSignal;
}

- (void)backAction:(id)sender{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)pust2View:(id)sender{
    RSSubViewController *subViewController = [[RSSubViewController alloc] initWithFrame:[UIScreen mainScreen].bounds andSignal:@""];
    NSArray *ar = [self.szSignal componentsSeparatedByString:@"--"];
    subViewController.szSignal = [NSString stringWithFormat:@"%@--%lu", [ar objectAtIndex:0], (unsigned long)[self.navigationController.viewControllers count]];

    [[QHSliderViewController sharedSliderController].navigationController pushViewController:subViewController animated:YES];
}

@end
